#include <iostream>
#include <limits.h>
int coinChange(int [], int, int);
int coinChange(int coins[], int len, int target)
{
    if (target == 0) return 0;
    if (target < 0) return -1;
    int res = INT_MAX;
    for(int i = 0; i < len; i++)
    {
        int temp = coinChange(coins, len, target - coins[i]);
        if (temp == -1) continue;
        res = res < temp + 1 ? res : temp + 1;
    }
    return res != INT_MAX ? res : -1;
} 

int main()
{   
    using namespace std;
    int coins[3] = {1, 2, 5};
    int target = 11;
    cout << coinChange(coins, 3, target) << endl;
    return 0;
}